using System.Data;
using ET;

namespace DAL
{
    public class Import_DAL
    {
        private static readonly clsConnect Cls = new clsConnect();

        #region Getdata
        public DataTable Search(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_tb_Import_Search");
        }
        public DataTable BindGirdtb_ImportDetail(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Import_ID", id);
            return Cls.GetData("sp_tb_Import_SelectRow");
        }
        public static DataTable GetImportFillterDate(string dateBegin, string dateEnd)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@DateBegin", dateBegin);
            Cls.AddParameter("@EndBegin", dateEnd);
            return Cls.GetData("sp_tb_Import_FillterDate");
        }
        public static DataTable GetImportFillter(string warehouseId, string roomId)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Warehouse_Id", warehouseId);
            Cls.AddParameter("@Room_ID", roomId);
            return Cls.GetData("sp_tb_Import_Fillter");
        }
        #endregion

        #region Insert
        public bool Inserttb_Import(Import_ET data)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Import_No", data.Import_No);
            Cls.AddParameter("@Import_Date", data.Import_Date);
            Cls.AddParameter("@Import_Provider", data.Import_Provider);
            Cls.AddParameter("@Proposed_ID", data.Proposed_ID);
            Cls.AddParameter("@Room_ID", data.Room_ID);
            Cls.AddParameter("@Warehouse_ID", data.Warehouse_ID);
            Cls.AddParameter("@Import_Note", data.Import_Note);
            Cls.AddParameter("@Import_Test", data.Import_Test);
            Cls.AddParameter("@Import_User_Add", data.Import_User_Add);
            Cls.AddParameter("@Import_Date_Add", data.Import_Date_Add);
            Cls.AddParameter("@Import_Computer_Add", data.Import_Computer_Add);
            data.Import_ID = Cls.ExecuteNonQueryReturnResult("sp_tb_Import_Insert", "@ReferenceID");
            return true;
        }
        #endregion

        #region Update
        public bool Updatetb_Import(Import_ET data)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Import_ID", data.Import_ID);
            Cls.AddParameter("@Import_No", data.Import_No);
            Cls.AddParameter("@Import_Date", data.Import_Date);
            Cls.AddParameter("@Import_Provider", data.Import_Provider);
            Cls.AddParameter("@Proposed_ID", data.Proposed_ID);
            Cls.AddParameter("@Room_ID", data.Room_ID);
            Cls.AddParameter("@Warehouse_ID", data.Warehouse_ID);
            Cls.AddParameter("@Import_Note", data.Import_Note);
            Cls.AddParameter("@Import_Test", data.Import_Test);
            Cls.AddParameter("@Import_User_Modify", data.Import_User_Modify);
            Cls.AddParameter("@Import_Date_Modify", data.Import_Date_Modify);
            Cls.AddParameter("@Import_Computer_Modify", data.Import_Computer_Modify);
            return Cls.ExecuteNonQuery("sp_tb_Import_Update");
        }
        #endregion

        #region Delete
        public bool Deletetb_Import(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Import_ID", id);
            return Cls.ExecuteNonQuery("sp_tb_Import_Delete");
        }
        #endregion
    }
}